package com.yishusmt.mobsmt.utils;

import com.yishusmt.mobsmt.dto.base.Result;
import com.yishusmt.mobsmt.dto.response.Tips;
import com.yishusmt.mobsmt.enums.ResultCodeEnum;
import com.yishusmt.mobsmt.enums.VersionEnum;

/**
 *  提示信息
 *
 * @author zhangyi
 * @date 2018/8/9 17:12
 */
public class TipsUtil {

    /**
     * 反馈信息工具类
     *
     * @param object
     * @param o 返回对象信息
     * @return
     */
    public static Result returnTips(Object object,Object o){
        Tips tips = null;
        if(object instanceof ResultCodeEnum){
            ResultCodeEnum operationSuccess = (ResultCodeEnum)object;
            tips = new Tips(operationSuccess.desc(), operationSuccess.key(),o);
        }else if(object instanceof VersionEnum){
            VersionEnum versionEnum = (VersionEnum)object;
            tips = new Tips(versionEnum.desc(), versionEnum.key(),o);
        }
        return new Result(tips);
    }
}
